! Splash on the sphere (Chen 2021)

module sw_case10_mod

  use const_mod

  implicit none

  private

  public sw_case10

  real(8), parameter :: radius  = 6371.220d3
  real(8), parameter :: gravity = 9.80616d0
  real(8), parameter :: omega   = 0
  real(8), parameter :: gh0     = 50 * gravity
  real(8), parameter :: gh1     =  1 * gravity
  real(8), parameter :: R       = 500.0d3

contains

  subroutine sw_case10(lon, lat, u, v, gh, ghs, g, f, radi)

    real(8), intent(in ) :: lon
    real(8), intent(in ) :: lat
    real(8), intent(out), optional :: u
    real(8), intent(out), optional :: v
    real(8), intent(out), optional :: gh
    real(8), intent(out), optional :: ghs
    real(8), intent(out), optional :: g
    real(8), intent(out), optional :: f
    real(8), intent(out), optional :: radi

    real(8) d

    if(present(radi))radi = radius
    
    d = radius * (pi / 2.0d0 - lat)

    if (present(u  )) u   = 0
    if (present(v  )) v   = 0
    if (present(gh )) gh  = merge(gh0 + gh1 * cos(pi / 2._8 * d / R), gh0, d < R)
    if (present(ghs)) ghs = 0
    if (present(g  )) g   = gravity
    if (present(f  )) f   = 0

  end subroutine sw_case10

end module sw_case10_mod
